﻿using System.Windows;

namespace MahApps.Metro.IconPacks
{
    public class PackIconLevs : PackIconControlBase
    {
        public static readonly DependencyProperty KindProperty
            = DependencyProperty.Register(nameof(Kind), typeof(PackIconLevsKind), typeof(PackIconLevs), new PropertyMetadata(default(PackIconLevsKind), KindPropertyChangedCallback));

        private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != e.OldValue)
            {
                ((PackIconLevs)dependencyObject).UpdateData();
            }
        }

        public PackIconLevsKind Kind
        {
            get => (PackIconLevsKind)GetValue(KindProperty);
            set => SetValue(KindProperty, value);
        }

        static PackIconLevs()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconLevs), new FrameworkPropertyMetadata(typeof(PackIconLevs)));
        }

        public PackIconLevs()
        {
        }

        protected override void SetKind<TKind>(TKind iconKind)
        {
            this.SetCurrentValue(KindProperty, iconKind);
        }

        protected override void UpdateData()
        {
            if (Kind != default(PackIconLevsKind))
            {
                string data = null;
                PackIconLevsDataFactory.DataIndex.Value?.TryGetValue(Kind, out data);
                this.Data = data;
            }
            else
            {
                this.Data = null;
            }
        }
    }
}